var all = {
    "v": 'v1100',
    "userInfo": null, // 用户信息
    "menu": null, // menu
    // "a_url": "http://v3-a.xgwl.net.cn/", // a项目域名
    // "app_url": "http://v3-i.xgwl.net.cn/", // 应用域名
    //"a_url": "https://v3-a.xinhehonggu.com",
    "app_url": `${process.env.VUE_APP_A_URL}/`,
    'bpp_url': `${process.env.VUE_APP_B_URL}/`,
    'e_url':`${process.env.VUE_APP_E_URL}/`,
    "sertype": 1, //sertype
    "sys": {
        "isMenuOpen": true,
        "unsetMnu": [
            '结算与订单',
        ]
    },
    "topHis": [],
    "beyond": [],
}


var userinfo = JSON.parse(window.localStorage.getItem('userinfo'))
userinfo ? all.userInfo = userinfo : all.userInfo = null

var menu = JSON.parse(window.localStorage.getItem('menu'))
menu ? all.menu = menu : all.menu = null


//存用户信息
function setUserInfo(userInfo) {
    all.userInfo = userInfo
    window.localStorage.setItem('userinfo', JSON.stringify(userInfo))
}
//存menu
function setMenu(menu) {
    all.menu = menu
    window.localStorage.setItem('menu', JSON.stringify(menu))
}

function setTopHis(val) {
    all.topHis.push(val)
}

function setbeyond(val) {
    all.beyond.push(val)
}

function cleHis() {
    all.topHis = []
    all.beyond = []
}
//取
function get(str) {
    return all[str]
}

function init() {
    var userinfo = JSON.parse(window.localStorage.getItem('userinfo'))
    if (userinfo) {
        all.userInfo = userinfo
    }
}
//清空用户信息
function clear() {
    all.userInfo = null
    all.menu = null
}

function clearHis() {
    all.topHis = []
}


module.exports = {
    setUserInfo,
    setMenu,
    get,
    init,
    clear,
    setTopHis,
    clearHis,
    setbeyond,
    cleHis
}